home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / chem.dis < prev    next >
Text File  |  1995-03-23  |  3KB  |  106 lines

  1. Article 4658 of comp.sys.handhelds:
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!magnus.ircc.ohio-state.edu!news
  3. From: fseipel@hpuxa.ircc.ohio-state.edu (Frank Seipel)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: HP-48SX; subroutine (subscripted chemical formulae)
  6. Message-ID: <1991Feb28.213833.14277@magnus.ircc.ohio-state.edu>
  7. Date: 28 Feb 91 21:38:33 GMT
  8. Sender: news@magnus.ircc.ohio-state.edu
  9. Organization: The Ohio State University
  10. Lines: 90
  11. Originator: fseipel@hpuxa.ircc.ohio-state.edu
  12. Nntp-Posting-Host: hpuxa.ircc.ohio-state.edu
  13.  
  14.  
  15. Chemical Formula Display Utility (CFD)
  16.  
  17. by Frank Seipel
  18.  
  19.  The following is a short RPL subroutine, to be called CFD, and a short
  20. example program, Call, which demonstrates its use. The purpose of CFD
  21. is to provide a means of displaying subscripted chemical formulae in
  22. user programs.
  23.  
  24.  CFD takes three arguments, an x-coordinate (binary integer), a
  25. y-coordinate (binary integer), and a text string (formula to display).
  26. The formula will be superimposed on PICT, beginning at the location
  27. specified by your coordinates. Any numerals in the formula will be
  28. subscripted, so as to appear like a chemical formula you would write on
  29. paper. Optionally you may include an '@' character in the string. This
  30. is interpreted as: go to column #50d and add the rest of the string to
  31. PICT at once, without subscripts -- this may be useful in right-justifying
  32. the names of compounds next to their names (see example program).
  33.  See page 324 of the manual for a diagram showing the binary coordinate
  34. system; the upper left corner is { #0d #0d }, the bottom right corner
  35. is { #130 #63 }. To type '@' on the HP-48SX, key in: alpha, followed
  36. by blue shift, and then ENTER.
  37.  
  38.  I realize this program is rather straightforward, but it seems as if it
  39. would be something which will be written over and over by many people so
  40. I decided to post it to the net. I am working on a program to let you
  41. scroll through subscripted formulas of common compounds. Once I have this
  42. working I will write a program to compute specific enthalpy at a given
  43. temperature, and to display other physical properties such as boiling
  44. points, heats of formation, vaporization, and combustion.
  45.  
  46.  If you didn't guess, YES, I am studying Chemical Engineering...
  47.  
  48. --------------------- STO this program as 'CFD' --------------------
  49.  
  50. %%HP: T(3)A(R)F(.);
  51. \<< 0 \-> px py str cn
  52.   \<< 1 str SIZE
  53.     FOR j str j j
  54. SUB DUP NUM 'cn'
  55. STO
  56.       IF '57\>=cn AND
  57. cn\>=48'
  58.       THEN 1 \->GROB
  59. PICT SWAP px py 4 +
  60. 2 \->LIST SWAP REPL
  61. px 4 + 'px' STO
  62.       ELSE DUP
  63.         IF "@" SAME
  64.         THEN DROP
  65. str DUP SIZE j 1 +
  66. SWAP SUB 2 \->GROB
  67. PICT SWAP # 50d py
  68. 2 \->LIST SWAP REPL '
  69. j=80' DEFINE
  70.         ELSE 2
  71. \->GROB PICT SWAP px
  72. py 2 \->LIST SWAP
  73. REPL px 6 + 'px'
  74. STO
  75.         END
  76.       END
  77.     NEXT
  78.   \>>
  79. \>>
  80.  
  81. <END OF CDF>
  82.  
  83. ---------------- STO this program as 'Call' ------------------------
  84.  
  85. %%HP: T(3)A(R)F(.);
  86. \<< # 0d # 22d
  87. "H2SO4@Sulfuric Acid"
  88. CFD { } PVIEW
  89. \>>
  90.  
  91. ---------------- Second example ------------------------------------
  92.  
  93. Example calling sequence:
  94.  
  95. 4:             #0d
  96. 3:            #0d
  97. 2:   "CH3CH2CH3@Propane"
  98. 1:                  CFD
  99.  
  100. Then hit orange-shift-graph to display PICT to see the subscripted
  101. formula in the upper right hand corner of screen. See also 'Call', above.
  102. Note: You may wish to adjust how far '@' goes over horizontally, depending
  103. on the length of your formula.
  104.  
  105.  
  106.